#!/bin/bash

function print_help {
    echo Usage: $0 test_name [ OPTIONS ]
    echo "   OPTIONS:"
    echo "       -n num_circles      Number of figures in the test"
    echo "       -h heuristic        Heuristic to use for solving the problem"
    echo "       -i iterations       Number of maximum iterations"
    echo "       -c criterion        Criterion of quality for clusters"
    echo "       -g                  Only generate new case, do not solve"
    echo "       -s                  Only solve the case, do not generate"
    exit
}

if [ ! $1 ]
then
    print_help
fi

OUT=$1
shift

#Default values
N="4"
H="LS"
I="100000"
C="Davies-Bouldin"
Gen=true
Solve=true

while [ $1 ]
do
    if [ $1 = "-n" ]
    then
        if [ ! $2 ]; then print_help; fi
        N=$2
        shift
    elif [ $1 = "-h" ]
    then
        if [ ! $2 ]; then print_help; fi
        H=$2
        shift
    elif [ $1 = "-i" ]
    then
        if [ ! $2 ]; then print_help; fi
        I=$2
        shift
    elif [ $1 = "-c" ]
    then
        if [ ! $2 ]; then print_help; fi
        C=$2
        shift
    elif [ $1 = "-g" ]
    then
        Solve=false
    elif [ $1 = "-s" ]
    then
        Gen=false
    else
        print_help
    fi

    shift
done

if [ $Gen = true ]
then
    python other/figure_generator.py results/$OUT $N
fi

if [ $Solve = true ]
then
    bin/clustrophobia -f results/$OUT.data -n $N -h $H -c $C -o results/$OUT.clusters -i $I
    python other/output_plotter.py results/$OUT
fi
